package com.necsv;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;

public class CustomDialogActivity extends Activity
{
	View viewAd;
	AlertDialog alert;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.customdialog);
		//LayoutInflater inflater = getLayoutInflater();
		LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		viewAd = inflater.inflate(R.layout.ad_dialog,
                (ViewGroup) findViewById(R.id.layout_root));
		ImageView img = (ImageView)viewAd.findViewById(R.id.img_goWeb);
		img.setImageResource(R.drawable.huyen);
		img.setOnClickListener(new ImageView.OnClickListener(){

			   public void onClick(View arg0) {
			    // TODO Auto-generated method stub
			    Toast.makeText(getApplicationContext(), "Huyen Like Son", Toast.LENGTH_LONG).show();
			   }});
		
		
		AlertDialog.Builder builder = new Builder(this);
		builder.setView(viewAd);
		builder.setTitle("title");
		builder.setPositiveButton("OK", new OnClickListener() {
			
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				Toast.makeText(getBaseContext(), "OK", Toast.LENGTH_SHORT).show();
			}
		});
		builder.setNegativeButton("Cancel", new OnClickListener() {
			
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				Toast.makeText(getBaseContext(), "NO", Toast.LENGTH_SHORT).show();
			}
		});
		
		//ImageView img = (ImageView)builder
		alert = builder.create();
	
	}
	
	public void btn_onClick(View v)
	{
		
		alert.show();
	}
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		GoogleAnaTool.trackPage("/CustomDialog");
		GoogleAnaTool.trackReferrer("trackReferrerCustomdialog");
		super.onResume();
	}
}
